package com.tpo.jnotes.client.layer.view.dialogs.listeners;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

import com.tpo.jnotes.client.layer.view.dialogs.NBaseFrame;

public class NTitleMouseListener implements MouseMotionListener, MouseListener
{

    private int clickedX;
    private int clickedY;
    private final NBaseFrame noteFrame;

    public NTitleMouseListener( NBaseFrame aNoteFrame )
    {
        noteFrame = aNoteFrame;
    }

    @Override
    public void mouseClicked( MouseEvent aEvent )
    {
    }

    @Override
    public void mousePressed( MouseEvent aEvent )
    {
        clickedX = aEvent.getXOnScreen();
        clickedX = clickedX - noteFrame.getX();

        clickedY = aEvent.getYOnScreen();
        clickedY = clickedY - noteFrame.getY();
    }

    @Override
    public void mouseReleased( MouseEvent aEvent )
    {
    }

    @Override
    public void mouseEntered( MouseEvent aEvent )
    {
    }

    @Override
    public void mouseExited( MouseEvent aEvent )
    {
    }

    @Override
    public void mouseDragged( MouseEvent aEvent )
    {
        noteFrame.requestFocus();
        noteFrame.setLocation( aEvent.getXOnScreen() - clickedX, aEvent.getYOnScreen() - clickedY );
    }

    @Override
    public void mouseMoved( MouseEvent aEvent )
    {
    }

}
